package com.wjc.wjc.dao;


import com.wjc.wjc.unity.Record;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface RecordRepository extends JpaRepository<Record,Long> {

    @Query("select sc from Record sc where sc.opinion=false and sc.name=?1")
    List<Record> findAllByName(String name);

    @Transactional
    @Modifying
    @Query("update Record sc set sc.opinion = true where sc.id=?1")
    int updataOp(Long id);

    @Transactional
    @Modifying
    @Query("update Record sc set sc.remarks = ?2 where sc.id=?1")
    int updataRemarks(Long id,String remarks);


    @Query("select sc from Record sc where sc.opinion=?1")
    List<Record> findByOpinion(boolean opinion);
}
